﻿@model Auction_Intranet.Models.GroupInvitationsModel
@{
    ViewBag.Title = "Pending invitations";
}

<div class="page">
    <h2>Pending invitations for @Model.group.Name</h2>
    @Html.ActionLink("Back", "Index","Groups",null, new { @class = "subpage-back" })
    <section class="pending-invitations black-shadow-box">

            <ul class="invitation-list">
                <li class="invitation-title-item">
                        <span>Name</span>
                        <span>Department</span>
                        <span class="item-study">Study</span>
                        <span class="item-email">Email</span>
                        <span class="item-username">Username</span>  
                        <span class="item-remove"></span>
                </li>
                <li class="invitation-list-item first"></li>
                @foreach (var item in Model.groupInvitations)
                {
                    <li class="invitation-list-item">
                        <span><span class="item-title">Name:</span><span class="item-name">@item.User.Name</span></span>
                        <span><span class="item-title">Department:</span><span class="item-name">@item.User.Department</span></span>
                        <span class="item-study"><span class="item-title">Study:</span><span class="item-name">@item.User.Study</span></span>
                        <span class="item-email"><span class="item-title">Email:</span><span class="item-name">@item.User.Email</span></span>
                        <span class="item-username"><span class="item-title">Username:</span><span class="item-name">@item.User.Username</span></span>
                        <span class="item-remove dialog-remove-invitation"> 
                            @Html.ActionLink("remove", "RemoveInvitation", new { id = item.Id }, new { @class="remove-invitation", id = item.Id})
                        </span>
                    </li>   
                }
                <li class="invitation-list-item last"></li>
            </ul>
    </section>
</div>
<div class="remove-confirm" title="Remove invitation?">
    <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Are you sure you wish to remove this invitation ?</p>
</div>

<script type="text/javascript">
    $(function () {
        var selectedID = 0;
        $(".remove-invitation").click(function (e) {
            e.preventDefault();      
            selectedID = $(this).attr("id");
            $('.remove-confirm').dialog('open');
        });

        $(".remove-confirm").dialog({
            autoOpen: false,
            resizable: false,
            draggable: false,
            height: 160,
            width: 350,
            modal: true,
            buttons: {
                "Continue": function () {
                    $(this).dialog("close");
                    document.location.href = '/Groups/RemoveInvitation/' + selectedID;
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    });       
</script>